<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/common/taglib.jsp" %>
<%@ taglib prefix="validator" uri="http://www.springmodules.org/tags/commons-validator" %>
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><spring:message code="main.title"/></title>


<link href="/css/reset.css" type="text/css" rel="stylesheet" />
<link href="/css/common.css" type="text/css" rel="stylesheet" />
<link href="/css/layout.css" type="text/css" rel="stylesheet" />
<link href="/css/ui.css" type="text/css" rel="stylesheet" />


<validator:javascript formName="contentsVO" staticJavascript="false" xhtml="true" cdata="false"/>
<style type="text/css" media="all">
#wrapper {
	position:absolute; z-index:1;
	top:50px; bottom:0px; left:0;
	width:100%;
	
	overflow:auto;
}
</style>
<!--[if lt IE 9]>
<script type="text/javascript" src="js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript" src="<c:url value="/validator.do"/>"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="<c:url value="/js/iscroll.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/common.js" />"></script>
<script type="text/javascript" src="<c:url value="/js/board.js" />"></script>
<script type="text/javascript">
$(document).ready(function() {
	
});

//목록
function fncList(){
	window.location.href="/board/contentsList.do";
}

//상세폼
function fncSave(){
	var form = document.contentsVO;
	if(validateContentsVO(form)) {
		if(form.contentsGroupId.value == 0){
			form.action = "/board/insertContents.do";
			form.submit();
		} else {
			fncPasswordCheck();
			form.action = "/board/updateContents.do";
		}
		
	}
}

function fncPasswordCheck() {
	$.post("/board/checkPassword.do", $("#contentsVO").serialize(),
	        function(data){
	        	if (data.success == "true"){
	        		if(confirm("게시물을 수정하시겠습니까?")) {
	        			var form = document.contentsVO;
	        			form.action = "/board/updateContents.do";
	        			form.submit();
	        		}
	        	}else{
	        		alert(data.message);
	        	}
	        }, "json"
	    );
}
</script>
</head>
<body>
<div class="Layerpop"></div>
<div id="nahfWrap">
	<!-- Header -->
	<jsp:include page="../common/header.jsp"></jsp:include>
	<!--// Header -->
	<form:form commandName="contentsVO" name="contentsVO" method="post">
	<form:hidden path="boardId"/>
	<form:hidden path="contentsGroupId"/>
	<form:hidden path="contentsSeq"/>
	<form:hidden path="contentsDepth"/>
	<spring:message var="reporter" code="board.reporter" />
	<spring:message var="reporterMsg" code="board.input1.msg" arguments="${reporter}" />
	<spring:message var="email" code="board.email" />
	<spring:message var="emailMsg" code="board.input1.msg" arguments="${email}" />
	<spring:message var="password" code="board.password" />
	<spring:message var="passwordMsg" code="board.input2.msg" arguments="${password}" />
	<spring:message var="title" code="board.title" />
	<spring:message var="titleMsg" code="board.input2.msg" arguments="${title}" />
	<spring:message var="contents" code="board.contents" />
	<spring:message var="contentsMsg" code="board.input2.msg" arguments="${contents}" />
	<!-- Content -->
	
	<!-- 컨텐츠 -->
	<div id="container" class="bg_sub">
		<div class="sub_wrap">
			<!-- 내용영역 -->
			<div class="sub_content">
				<div class="left_menu">
					<h2><img src="/img/leftMenu7.png" alt="참여서비스"/></h2>
					<!-- left 메뉴 -->
					<div id="left">
						<ul class="navmenu navmenu7">
							<li class="nvparam1"><a href="/board/contentsList.do?boardId=01">공지사항</a></li>
							<li class="nvparam2"><a href="/board/contentsList.do?boardId=02">묻고답하기</a></li>
						</ul>
					</div>
					<!-- //left 메뉴 -->
				</div>
				<div class="sub_area">
					<!-- 서브 네비게이션 -->
					<ul class="sub_navi">
						<li><a href="/"><img src="/img/sub_navi1.gif" alt="home"/></a></li>
						<li><a href="#">참여서비스</a></li>
						<c:if test="${searchVO.boardId eq '01'}">
						<li class="sel_navi"><a href="/board/contentsList.do?boardId=01">공지사항</a></li>
						</c:if>
						<c:if test="${searchVO.boardId eq '02'}">
						<li class="sel_navi"><a href="/board/contentsList.do?boardId=02">묻고 답하기</a></li>
						</c:if>
					</ul>
					<!-- //서브 네비게이션 -->
					<div class="sub_tit">
						<c:if test="${searchVO.boardId eq '01'}">
						<h3><img src="/img/subMenu_tit11.gif" alt="공지사항"/></h3>
						</c:if>
						<c:if test="${searchVO.boardId eq '02'}">
						<h3><img src="/img/subMenu_tit10.gif" alt="묻고 답하기"/></h3>
						</c:if>
					</div>
					<!-- 내용 -->
					<div class="mr37 ">
						<!-- 리스트 목록 -->
						<div class="tb_sch_list">
							<table>
								<tbody>
									<tr>
										<th scope="row">작성자</th>
										<td>
											<form:input path="writerNm" title="${writerNm}" placeholder="${reporterMsg}" />
										</td>
									</tr>
									<tr>
										<th scope="row">EMAIL</th>
										<td>
											<form:input path="email" title="${email}" placeholder="${emailMsg}"/>
										</td>
									</tr>
									<tr>
										<th scope="row">비밀번호</th>
										<td>
											<input type="password" name="password" id="password" title="${password }" placeholder="${passwordMsg}"/>
										</td>
									</tr>
									<tr>
										<th scope="row">제목</th>
										<td>
											<form:input path="contentsNm" title="${contentsNm}" class="it419"  placeholder="${titleMsg}"/>
										</td>
									</tr>
									<tr>
										<th scope="row">첨부파일</th>
										<td>
											<input type="file" class="multi"/>
											<!-- <input type="file" title="첨부파일" name="filename" class="fileUp multi" id="reg_file" /> -->
										</td>
									</tr>
									<tr>
										<td scope="row" colspan="2">
											<div class="editor">
												<form:textarea path="contentsDesc" rows="20" cols="115" title="${contentsDesc}" placeholder="${contentsMsg}"></form:textarea>
											</div>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
						<!-- //리스트 목록 -->
						<!-- 버튼 -->
						<div class="btn_area">
							<div class="t_center">
								<a href="javascript:fncSave()" class="btn_list_view"><span>확인</span></a>
								<a href="/board/contentsList.do?boardId=02" class="btn_list_view"><span>목록</span></a>
							</div>
						</div>
						<!-- //버튼 -->
					</div>
					<!-- //내용 -->	
				</div>
			</div>
			<!-- //내용영역 -->
		</div>
	</div>
	<!-- //컨텐츠 -->
	<!--// Content -->
	
	</form:form>
	<!--// Content -->

	<jsp:include page="../common/footer.jsp"></jsp:include>
</div>
</body>
</html>